﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PServiceBus.Core.Interface {
    /// <summary>
    /// Interface for implementing subscription manager which are used when subscription to the bus is requested
    /// </summary>
    public interface ISubscriptionManager : IDisposable {
        /// <summary>
        /// Return underlying provider for subscribers
        /// </summary>
        IObjectProvider<ISubscriber> Provider { get; }
        /// <summary>
        /// Address of subscription data store
        /// </summary>
        string Address { get; set; }
        /// <summary>
        /// Startup of subscription manager
        /// </summary>
        void Init();
        /// <summary>
        /// Add new subscriber
        /// </summary>
        /// <param name="subscriber"></param>
        ISubscriber AddSubscriber(ISubscriber subscriber);
        /// <summary>
        /// Update existing subscriber
        /// </summary>
        /// <param name="subscriber"></param>
        void UpdateSubscriber(ISubscriber subscriber);
        /// <summary>
        /// Delete subscriber if exists
        /// </summary>
        /// <param name="name"></param>
        void DeleteSubscriber(string name);
        /// <summary>
        /// Delete a specific transport from subscriber subscription
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="transportName"></param>
        void DeleteTransport(string subscriber, string transportName);
        /// <summary>
        /// Add a new transport to subscriber
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="transportName"></param>
        /// <param name="transport"></param>
        /// <param name="topicID"></param>
        void AddTransport(string subscriber, string transportName, ITransport transport, Guid topicID);
        /// <summary>
        /// Unsubscribe from existing topic
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="topicID"></param>
        /// <param name="topicName"></param>
        void UnSubscribeFrom(string subscriber, Guid topicID, string topicName);
        /// <summary>
        /// Subscribe to existing topic
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="topicID"></param>
        /// <param name="topicName"></param>
        /// <param name="filter"></param>
        /// <param name="needHeader"></param>
        void SubscribeTo(string subscriber, Guid topicID, string topicName, string filter, bool needHeader, bool caseSensitive);
        /// <summary>
        /// Update subscriber subscription
        /// </summary>
        /// <param name="subscriber"></param>
        /// <param name="topicName"></param>
        /// <param name="filter"></param>
        /// <param name="needHeader"></param>
        /// <param name="caseSensitive"></param>
        void UpdateSubscriber(string subscriber, string topicName, string filter, bool needHeader, bool caseSensitive);
        /// <summary>
        /// Register a new topic
        /// </summary>
        /// <param name="topic"></param>
        void RegisterTopic(ITopic topic);
    }
}
